/****************************************************/
*Fairness: Analysis									*/
*Date Created: February 13, 2022					*/
*Notes: Fairness Data Analysis - Tables				*/
/****************************************************/

* This do file contains the tables/regressions of fairness paper
************************************************************************
*MAIN TABLES:
***2. Shares: Last 10 rounds

*APPENDIX TABLES:
***B1a. Shares: All 30 rounds
***B1b. Shares: First 10 rounds
***B1c. Same as main table 2 (see above)

***B2. Reg - Shares: Last 10 rounds
***B3. Reg - Shares: All 30 rounds
***B4. Reg - Shares: First 10 rounds
***B5. Reg - Shares: Learning (XLast10)

***B6a. Shares by School: All 30 rounds
***B6b. Shares by School: First 10 rounds
***B6c. Shares by School: Last 10 rounds

***B7a. Shares with session clusters: All 30 rounds
***B7b. Shares with session clusters: First 10 rounds
***B7c. Shares with session clusters: Last 10 rounds


***B8a. Alt Defn Inequality: All 30 rounds
***B8b. Alt Defn Inequality: First 10 rounds
***B8c. Alt Defn Inequality: Last 10 rounds
***B9. Reg - Alt Defn Inequality: All 30 rounds
***B10. Reg - Alt Defn Inequality: First 10 rounds
***B11. Reg - Alt Defn Inequality: Last 10 rounds

***B12. Buyer Offer: 4 Panels 
*********B12a. Regressions: Offer Removing Buyer Info | Seller Informed (SK v CI)
*********B12b. Regressions: Offer Removing Buyer Info | Seller Uninformed (NK v BK)
*********B12c. Regressions: Offer Removing Seller Info | Buyer Informed (BK v CI)
*********B12d. Regressions: Offer Removing Seller Info | Buyer Uninformed (NK v SK)

***B13. Seller Accept: 4 Panels
*********B13a. Regressions: Accepted Removing Buyer Info | Seller Informed (SK v CI)
*********B13b. Regressions: Accepted Removing Buyer Info | Seller Uninformed  (NK v BK)
*********B13c. Regressions: Accepted Removing Seller Info | Buyer Informed (BK v CI)
*********B13d. Regressions: Accepted Removing Seller Info | Buyer Uninformed (NK v SK)

***B14a. KS-test: Seller Beliefs v. Reality NK
***B14b. KS-test: Seller Beliefs v. Reality BK
************************************************************************

clear all
set more off

/****************************************/
/*				PREAMBLE	 			*/
/****************************************/

*Set directories: Change local directory paths
global raw_dir "<INSERT RAW DATA DIRECTORY HERE>"
global out_dir_gph "<INSERT OUTPUT DIRECTORY FOR FIGRUES HERE>"
global out_dir_tbl "<INSERT OUTPUT DIRECTORY FOR TABLES HERE>"
cd "$raw_dir"


*****************************************
*** READ / PREP DATA
*****************************************

use fairness_part1, replace
gen temp = 1

bys session period group: egen subj_id_buyer = total(subj_id) if buyer==1
bys session period group: egen subj_id_seller = total(subj_id) if buyer==0
bys session period group: egen subj_id_buyer2 = sum(subj_id_buyer)
bys session period group: egen subj_id_seller2 = sum(subj_id_seller)
drop subj_id_buyer subj_id_seller

gen wharton = .	
	replace wharton= 0  if sessionfile == "120509_1658"
	replace wharton= 0  if sessionfile == "120509_1855"
	replace wharton= 0  if sessionfile == "120514_1712"
	replace wharton= 0  if sessionfile == "120516_1646"
	replace wharton= 0  if sessionfile == "120522_1938"
	replace wharton= 0  if sessionfile == "120524_1736"
	replace wharton= 0  if sessionfile == "120529_1820"
	replace wharton= 0  if sessionfile == "120604_1909"
	replace wharton= 1  if sessionfile == "120614_1120"
	replace wharton= 1  if sessionfile == "120614_1248"
	replace wharton= 1  if sessionfile == "120614_1356"
	replace wharton= 1  if sessionfile == "120615_1109"
	replace wharton= 1  if sessionfile == "120615_1234"
	replace wharton= 1  if sessionfile == "120615_1419"
	replace wharton= 1  if sessionfile == "120618_1149"
	replace wharton= 1  if sessionfile == "120618_1350"
	replace wharton= 1  if sessionfile == "120619_1130"
	replace wharton= 1  if sessionfile == "120619_1343"
	replace wharton= 1  if sessionfile == "120620_1136"
	replace wharton= 1  if sessionfile == "120620_1345"
label variable wharton "Ran at Wharton?"

*gen reject
gen rejectoffer = (accept == 0)*100

*gen buyer, seller and inequality share: 
gen buyershare=(earnings/(earnings+otherearnings))*100 if buyer==1
	replace buyershare=0 if accept==0 & buyer==1

gen sellershare=(earnings/(earnings+otherearnings))*100 if buyer==0
	replace sellershare=0 if accept==0 & buyer==0
	
gen ownshare=(earnings/(earnings+otherearnings))*100
	replace ownshare=0 if accept==0	
		
gen othershare=(otherearnings/(earnings+otherearnings))*100
	replace othershare=0 if accept==0 
	
*inequalityshare== max( buyer earnings - seller earnings, 0) / (v-c)
gen inequalityshare=. 
	replace inequalityshare=(max(earnings-otherearnings,0)/(value-othercost))*100  if buyer==1
	replace inequalityshare=(max(otherearnings-earnings,0)/(othervalue-cost))*100  if buyer==0
	
*absolute inequality 
gen absinequalityshare=. 
	replace absinequalityshare=(abs(earnings-otherearnings)/(value-othercost))*100  if buyer==1
	replace absinequalityshare=(abs(otherearnings-earnings)/(othervalue-cost))*100  if buyer==0
	
*difference inequality	
gen diffinequalityshare=. 
	replace diffinequalityshare=((earnings-otherearnings)/(value-othercost))*100  if buyer==1
	replace diffinequalityshare=((otherearnings-earnings)/(othervalue-cost))*100  if buyer==0	

egen totalshare=rowtotal(ownshare othershare)		

gen nooneknows=0
	replace nooneknows=1 if treatment==1
label variable nooneknows "Neither Knows (NK)"			

gen sellerknows=0
	replace sellerknows=1 if treatment==2
label variable sellerknows "Seller Knows (SK)"	
		
gen buyerknows=0
	replace buyerknows=1 if treatment==3
label variable buyerknows "Buyer Knows (BK)"

*set fair offer range
gen buffer=2

gen unfairtoseller=0
	replace unfairtoseller=100 if cost==10 & othervalue==70 & offer<40-buffer
	replace unfairtoseller=100 if cost==30 & othervalue==70 & offer<50-buffer
	replace unfairtoseller=100 if cost==10 & othervalue==90 & offer<50-buffer
	replace unfairtoseller=100 if cost==30 & othervalue==90 & offer<60-buffer
	
gen generoustoseller=0
	replace generoustoseller=100 if cost==10 & othervalue==70 & offer>40+buffer
	replace generoustoseller=100 if cost==30 & othervalue==70 & offer>50+buffer
	replace generoustoseller=100 if cost==10 & othervalue==90 & offer>50+buffer
	replace generoustoseller=100 if cost==30 & othervalue==90 & offer>60+buffer
	
gen neither=0
	replace neither=100 if cost==10 & othervalue==70 & offer>=40-buffer & offer<=40+buffer
	replace neither=100 if cost==30 & othervalue==70 & offer>=50-buffer & offer<=50+buffer
	replace neither=100 if cost==10 & othervalue==90 & offer>=50-buffer & offer<=50+buffer
	replace neither=100 if cost==30 & othervalue==90 & offer>=60-buffer & offer<=60+buffer	
	
gen fairgenerousoffers=.
	replace fairgenerousoffers=-1 if unfairtoseller==1
	replace fairgenerousoffers=0 if neither==1
	replace fairgenerousoffers=1 if generoustoseller==1

egen session_id=group(session)	
egen numeric_id=group(subj_id)
egen buyer_id = group(subj_id_buyer2)		
egen seller_id = group(subj_id_seller) 		
	
preserve

*****************************************
*			MAIN TABLES					*
*****************************************

****************************************
***2. Shares: Last 10 rounds
****************************************

keep if period>20

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_last10rounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{Last 10 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	 

restore, preserve


*****************************************
*			APPENDIX TABLES				*
*****************************************

****************************************
***B1a. Shares: All 30 rounds
****************************************
*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_allrounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{All 30 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	

restore, preserve
****************************************
***B1b. Shares: First 10 rounds
****************************************

keep if period<=10

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_first10rounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{First 10 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 			
	

****************************************
***B1c. Shares: Last 10 rounds
****************************************

* SAME AS MAIN TABLE 2 SEE ABOVE 

****************************************
***B2. Reg - Shares: Last 10 rounds
****************************************
restore, preserve
keep if period>20

***BUYER SHARE
	reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local BStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local BStestBKvsNK: di %5.3f r(p)	

***SELLER SHARE				
	reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local SStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local SStestBKvsNK: di %5.3f r(p)	
		
***INEQUALITY SHARE		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)				

***TOTAL SHARE					
	reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo D
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local TStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local TStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_last10rounds_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l cccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Buyer} & \textbf{Seller} & \textbf{Inequality} & \textbf{Total}\\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///	        
				"\cmidrule(lr){2-5} & (1) & (2) & (3) & (4) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `BStestSKvsNK' & `SStestSKvsNK' & `IStestSKvsNK' & `TStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `BStestBKvsNK' & `SStestBKvsNK' & `IStestBKvsNK' &  `TStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear


****************************************
***B3. Reg - Shares: All 30 rounds
****************************************
restore, preserve

***BUYER SHARE
	reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local BStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local BStestBKvsNK: di %5.3f r(p)	

***SELLER SHARE				
	reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local SStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local SStestBKvsNK: di %5.3f r(p)	
		
***INEQUALITY SHARE		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)				

***TOTAL SHARE					
	reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo D
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local TStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local TStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_all30_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l cccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Buyer} & \textbf{Seller} & \textbf{Inequality} & \textbf{Total}\\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///	        
				"\cmidrule(lr){2-5} & (1) & (2) & (3) & (4) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `BStestSKvsNK' & `SStestSKvsNK' & `IStestSKvsNK' & `TStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `BStestBKvsNK' & `SStestBKvsNK' & `IStestBKvsNK' &  `TStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
		

****************************************
***B4. Reg - Shares: First 10 rounds
****************************************
restore, preserve
keep if period<=10

***BUYER SHARE
	reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local BStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local BStestBKvsNK: di %5.3f r(p)	

***SELLER SHARE				
	reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local SStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local SStestBKvsNK: di %5.3f r(p)	
		
***INEQUALITY SHARE		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)				

***TOTAL SHARE					
	reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)			
			eststo D
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local TStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local TStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_first10rounds_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l cccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Buyer} & \textbf{Seller} & \textbf{Inequality} & \textbf{Total}\\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///	        
				"\cmidrule(lr){2-5} & (1) & (2) & (3) & (4) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `BStestSKvsNK' & `SStestSKvsNK' & `IStestSKvsNK' & `TStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `BStestBKvsNK' & `SStestBKvsNK' & `IStestBKvsNK' &  `TStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
				

****************************************
***B5. Reg - Shares: Learning (XLast10)
****************************************
restore, preserve

*keep only first 10 and last 10 rounds
drop if period>10 & period<=20	

gen last10rounds=0
	replace last10rounds=1 if period>20
	
gen sellerknows_last=sellerknows*last10rounds
gen buyerknows_last=buyerknows*last10rounds
gen nooneknows_last=nooneknows*last10rounds


label variable last10rounds "Last 10 Round"
label variable sellerknows_last "Seller Knows $\times$ Last 10 Round"
label variable buyerknows_last "Buyer Knows $\times$ Last 10 Round"
label variable nooneknows_last "Neither Knows $\times$ Last 10 Round"	

eststo clear

*BINARY

***BUYER SHARE
reghdfe buyershare sellerknows_last buyerknows_last nooneknows_last ///
		sellerknows buyerknows nooneknows last10rounds if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	eststo A
    estadd local indcluster `e(N_clust)', replace	

***SELLER SHARE	
reghdfe sellershare sellerknows_last buyerknows_last nooneknows_last ///
		sellerknows buyerknows nooneknows last10rounds if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	eststo B
    estadd local indcluster `e(N_clust)', replace				
		
***INEQUALITY SHARE		
reghdfe inequalityshare sellerknows_last buyerknows_last nooneknows_last ///
		sellerknows buyerknows nooneknows last10rounds if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	eststo C
    estadd local indcluster `e(N_clust)', replace			

***TOTAL SHARE					
reghdfe totalshare sellerknows_last buyerknows_last nooneknows_last ///
		sellerknows buyerknows nooneknows last10rounds if buyer==0, absorb(temp) cluster(buyer_id seller_id)
	eststo D
    estadd local indcluster `e(N_clust)', replace	

*export table code		
		esttab using "$out_dir_tbl/reg_learning_firstvlast10_v2.tex", ///
			keep(sellerknows_last buyerknows_last nooneknows_last last10rounds sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows_last buyerknows_last nooneknows_last sellerknows buyerknows nooneknows last10rounds _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l cccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Buyer} & \textbf{Seller} & \textbf{Inequality} & \textbf{Total}\\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///	        
				"\cmidrule(lr){2-5} & (1) & (2) & (3) & (4) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
		

****************************************
***B6a. Shares by School: All 30 rounds
****************************************
restore, preserve	

*collect p-values to put into stars later
*IS
reghdfe inequalityshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_CI = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_BK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_NK = resultsmat[4,1]	

*BS	
reghdfe buyershare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_CI = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_BK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_NK = resultsmat[4,1]
	
*SS	
reghdfe sellershare wharton if treatment==4 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_CI = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==3 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_BK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==2 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==1 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_NK = resultsmat[4,1]		

*TS	
reghdfe totalshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_CI = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_BK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_NK = resultsmat[4,1]		
	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_TS=totalshare, by(treatment wharton)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="CI" if n==1
replace treatment="SK" if n==2
replace treatment="BK" if n==3
replace treatment="NK" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

reshape wide mean* , i(treatment) j(wharton)

gen p_BS=.
replace p_BS=round(`p_BS_CI',0.01) if n==1
replace p_BS=round(`p_BS_SK',0.01) if n==2
replace p_BS=round(`p_BS_BK',0.01) if n==3
replace p_BS=round(`p_BS_NK',0.01) if n==4
	
gen p_SS=.
replace p_SS=round(`p_SS_CI',0.01) if n==1
replace p_SS=round(`p_SS_SK',0.01) if n==2
replace p_SS=round(`p_SS_BK',0.01) if n==3
replace p_SS=round(`p_SS_NK',0.01) if n==4

gen p_IS=.
replace p_IS=round(`p_IS_CI',0.01) if n==1
replace p_IS=round(`p_IS_SK',0.01) if n==2
replace p_IS=round(`p_IS_BK',0.01) if n==3
replace p_IS=round(`p_IS_NK',0.01) if n==4
	
gen p_TS=.
replace p_TS=round(`p_TS_CI',0.01) if n==1
replace p_TS=round(`p_TS_SK',0.01) if n==2
replace p_TS=round(`p_TS_BK',0.01) if n==3
replace p_TS=round(`p_TS_NK',0.01) if n==4

format p_BS-p_TS %8.2f	

sort n

order treatment mean_IS0 mean_IS1 p_IS ///
			mean_BS0 mean_BS1 p_BS ///
			mean_SS0 mean_SS1 p_SS ///
			mean_TS0 mean_TS1 p_TS 
drop n

listtex using "$out_dir_tbl/Fairness_shares_allrounds_v2_byschool.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{L{0.5cm} C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} } \toprule " ///
		 " & \multicolumn{12}{c}{\textbf{All 30 Rounds}} \\ \midrule  " ///
		 " & \multicolumn{3}{c|}{\textbf{Inequality Share}} & \multicolumn{3}{c|}{\textbf{Buyer Share}} & \multicolumn{3}{c|}{\textbf{Seller Share}} & \multicolumn{3}{c}{\textbf{Total Share}}\\ " ///
		 " & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}  & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	


****************************************
***B6b. Shares by School: First 10 rounds
****************************************
restore, preserve
keep if period<=10
*collect p-values to put into stars later

*IS
reghdfe inequalityshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_CI = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_BK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_NK = resultsmat[4,1]	

*BS	
reghdfe buyershare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_CI = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_BK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_NK = resultsmat[4,1]
	
*SS	
reghdfe sellershare wharton if treatment==4 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_CI = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==3 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_BK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==2 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==1 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_NK = resultsmat[4,1]		

*TS	
reghdfe totalshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_CI = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_BK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_NK = resultsmat[4,1]		
	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_TS=totalshare, by(treatment wharton)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="CI" if n==1
replace treatment="SK" if n==2
replace treatment="BK" if n==3
replace treatment="NK" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

reshape wide mean* , i(treatment) j(wharton)

gen p_BS=.
replace p_BS=round(`p_BS_CI',0.01) if n==1
replace p_BS=round(`p_BS_SK',0.01) if n==2
replace p_BS=round(`p_BS_BK',0.01) if n==3
replace p_BS=round(`p_BS_NK',0.01) if n==4
	
gen p_SS=.
replace p_SS=round(`p_SS_CI',0.01) if n==1
replace p_SS=round(`p_SS_SK',0.01) if n==2
replace p_SS=round(`p_SS_BK',0.01) if n==3
replace p_SS=round(`p_SS_NK',0.01) if n==4

gen p_IS=.
replace p_IS=round(`p_IS_CI',0.01) if n==1
replace p_IS=round(`p_IS_SK',0.01) if n==2
replace p_IS=round(`p_IS_BK',0.01) if n==3
replace p_IS=round(`p_IS_NK',0.01) if n==4
	
gen p_TS=.
replace p_TS=round(`p_TS_CI',0.01) if n==1
replace p_TS=round(`p_TS_SK',0.01) if n==2
replace p_TS=round(`p_TS_BK',0.01) if n==3
replace p_TS=round(`p_TS_NK',0.01) if n==4

format p_BS-p_TS %8.2f	


sort n

order treatment mean_IS0 mean_IS1 p_IS ///
			mean_BS0 mean_BS1 p_BS ///
			mean_SS0 mean_SS1 p_SS ///
			mean_TS0 mean_TS1 p_TS 
drop n

listtex using "$out_dir_tbl/Fairness_shares_first10rounds_v2_byschool.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{L{0.5cm} C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} } \toprule " ///
		 " & \multicolumn{12}{c}{\textbf{First 10 Rounds}} \\ \midrule  " ///
		 " & \multicolumn{3}{c|}{\textbf{Inequality Share}} & \multicolumn{3}{c|}{\textbf{Buyer Share}} & \multicolumn{3}{c|}{\textbf{Seller Share}} & \multicolumn{3}{c}{\textbf{Total Share}}\\ " ///
		 " & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}  & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 			
	

****************************************
***B6c. Shares by School: Last 10 rounds
****************************************
restore, preserve
keep if period>20
*collect p-values to put into stars later

*IS
reghdfe inequalityshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_CI = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_BK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	
reghdfe inequalityshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_NK = resultsmat[4,1]	

*BS	
reghdfe buyershare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_CI = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_BK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	
reghdfe buyershare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_BS_NK = resultsmat[4,1]
	
*SS	
reghdfe sellershare wharton if treatment==4 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_CI = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==3 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_BK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==2 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	
reghdfe sellershare wharton if treatment==1 & buyer==0, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_SS_NK = resultsmat[4,1]		

*TS	
reghdfe totalshare wharton if treatment==4 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_CI = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==3 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_BK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==2 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	
reghdfe totalshare wharton if treatment==1 & buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_TS_NK = resultsmat[4,1]		
	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_TS=totalshare, by(treatment wharton)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="CI" if n==1
replace treatment="SK" if n==2
replace treatment="BK" if n==3
replace treatment="NK" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

reshape wide mean* , i(treatment) j(wharton)

gen p_BS=.
replace p_BS=round(`p_BS_CI',0.01) if n==1
replace p_BS=round(`p_BS_SK',0.01) if n==2
replace p_BS=round(`p_BS_BK',0.01) if n==3
replace p_BS=round(`p_BS_NK',0.01) if n==4
	
gen p_SS=.
replace p_SS=round(`p_SS_CI',0.01) if n==1
replace p_SS=round(`p_SS_SK',0.01) if n==2
replace p_SS=round(`p_SS_BK',0.01) if n==3
replace p_SS=round(`p_SS_NK',0.01) if n==4

gen p_IS=.
replace p_IS=round(`p_IS_CI',0.01) if n==1
replace p_IS=round(`p_IS_SK',0.01) if n==2
replace p_IS=round(`p_IS_BK',0.01) if n==3
replace p_IS=round(`p_IS_NK',0.01) if n==4
	
gen p_TS=.
replace p_TS=round(`p_TS_CI',0.01) if n==1
replace p_TS=round(`p_TS_SK',0.01) if n==2
replace p_TS=round(`p_TS_BK',0.01) if n==3
replace p_TS=round(`p_TS_NK',0.01) if n==4

format p_BS-p_TS %8.2f	

sort n

order treatment mean_IS0 mean_IS1 p_IS ///
			mean_BS0 mean_BS1 p_BS ///
			mean_SS0 mean_SS1 p_SS ///
			mean_TS0 mean_TS1 p_TS 
drop n

listtex using "$out_dir_tbl/Fairness_shares_last10rounds_v2_byschool.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{L{0.5cm} C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} |C{0.9cm}C{0.9cm}C{0.5cm} } \toprule " ///
		 " & \multicolumn{12}{c}{\textbf{Last 10 Rounds}} \\ \midrule  " ///
		 " & \multicolumn{3}{c|}{\textbf{Inequality Share}} & \multicolumn{3}{c|}{\textbf{Buyer Share}} & \multicolumn{3}{c|}{\textbf{Seller Share}} & \multicolumn{3}{c}{\textbf{Total Share}}\\ " ///
		 " & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p} & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}  & \tiny{Stan.} & \tiny{Whar.} & \tiny{p}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}")
		

****************************************
***B7a. Shares with session clusters: All 30 rounds
****************************************
restore, preserve

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_allrounds_v2_sessionclusters.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{All 30 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	


****************************************
***B7b. Shares with session clusters: First 10 rounds
****************************************
restore, preserve
keep if period<=10

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_first10rounds_v2_sessionclusters.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{First 10 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 			

	
****************************************
***B7c. Shares with session clusters: Last 10 rounds
****************************************
restore, preserve
keep if period>20

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]

reghdfe buyershare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_BS_SK = resultsmat[4,1]
	local p_BS_BK = resultsmat[4,2]
	local p_BS_NK = resultsmat[4,3]
	
reghdfe sellershare sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_SS_SK = resultsmat[4,1]
	local p_SS_BK = resultsmat[4,2]
	local p_SS_NK = resultsmat[4,3]
	
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe totalshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_TS_SK = resultsmat[4,1]
	local p_TS_BK = resultsmat[4,2]
	local p_TS_NK = resultsmat[4,3]
	
reghdfe rejectoffer sellerknows buyerknows nooneknows if buyer==0, absorb(temp) cluster(session_id)
	mat resultsmat=r(table)
	local p_RO_SK = resultsmat[4,1]
	local p_RO_BK = resultsmat[4,2]
	local p_RO_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_BS=buyershare ///
		 (mean) mean_SS=sellershare ///
		 (mean) mean_IS=inequalityshare ///
		 (mean) mean_RO=rejectoffer ///
		 (mean) mean_TS=totalshare, by(treatment)
				
format mean_BS-mean_TS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_BS=round(mean_BS,0.01)
replace mean_SS=round(mean_SS,0.01)
replace mean_IS=round(mean_IS,0.01)
replace mean_RO=round(mean_RO,0.01)
replace mean_TS=round(mean_TS,0.01)

format mean_BS-mean_TS %8.2f	

gen p_BS=.
replace p_BS=round(`p_BS_SK',0.0001) if n==2
replace p_BS=round(`p_BS_BK',0.0001) if n==3
replace p_BS=round(`p_BS_NK',0.0001) if n==4

gen BS_stars = "" 
	replace BS_stars = "\sym{*}" if p_BS >= 0.05 & p_BS <0.10
	replace BS_stars = "\sym{**}" if p_BS >= 0.01 & p_BS <0.05
	replace BS_stars = "\sym{***}" if p_BS >= 0 & p_BS <0.01
	
gen p_SS=.
replace p_SS=round(`p_SS_SK',0.0001) if n==2
replace p_SS=round(`p_SS_BK',0.0001) if n==3
replace p_SS=round(`p_SS_NK',0.0001) if n==4

gen SS_stars = "" 
	replace SS_stars = "\sym{*}" if p_SS >= 0.05 & p_SS <0.10
	replace SS_stars = "\sym{**}" if p_SS >= 0.01 & p_SS <0.05
	replace SS_stars = "\sym{***}" if p_SS >= 0.00 & p_SS <0.01	

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_RO=.
replace p_RO=round(`p_RO_SK',0.0001) if n==2
replace p_RO=round(`p_RO_BK',0.0001) if n==3
replace p_RO=round(`p_RO_NK',0.0001) if n==4

gen RO_stars = "" 
	replace RO_stars = "\sym{*}" if p_RO >= 0.05 & p_RO <0.10
	replace RO_stars = "\sym{**}" if p_RO >= 0.01 & p_RO <0.05
	replace RO_stars = "\sym{***}" if p_RO >= 0.00 & p_RO <0.01		
	
gen p_TS=.
replace p_TS=round(`p_TS_SK',0.0001) if n==2
replace p_TS=round(`p_TS_BK',0.0001) if n==3
replace p_TS=round(`p_TS_NK',0.0001) if n==4

gen TS_stars = "" 
	replace TS_stars = "\sym{*}" if p_TS >= 0.05 & p_TS <0.10
	replace TS_stars = "\sym{**}" if p_TS >= 0.01 & p_TS <0.05
	replace TS_stars = "\sym{***}" if p_TS >= 0.00 & p_TS <0.01	
	
gen BS = string(mean_BS, "%8.2f")+BS_stars	
gen SS = string(mean_SS, "%8.2f")+SS_stars	
gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen RO = string(mean_RO, "%8.2f")+RO_stars	
gen TS = string(mean_TS, "%8.2f")+TS_stars	

keep treatment IS BS SS TS RO
order treatment IS BS SS TS RO

listtex using "$out_dir_tbl/Fairness_shares_last10rounds_v2_sessionclusters.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccc} \toprule " ///
		 " & \multicolumn{5}{c}{\textbf{Last 10 Rounds}} \\ \midrule  " ///
		 "\multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Buyer} & \textbf{Seller} & \textbf{Total} & \textbf{Rejection}\\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Share} & \textbf{Rate}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	 
			
			
****************************************
***B8a. Alt Defn Inequality: All 30 rounds (absinequalityshare diffinequalityshare)
****************************************	
restore, preserve

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_AIS_SK = resultsmat[4,1]
	local p_AIS_BK = resultsmat[4,2]
	local p_AIS_NK = resultsmat[4,3]
	
reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_DIS_SK = resultsmat[4,1]
	local p_DIS_BK = resultsmat[4,2]
	local p_DIS_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_IS=inequalityshare ///
		 (mean) mean_AIS=absinequalityshare ///
		 (mean) mean_DIS=diffinequalityshare, by(treatment)
				
format mean_IS-mean_DIS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_IS=round(mean_IS,0.01)
replace mean_AIS=round(mean_AIS,0.01)
replace mean_DIS=round(mean_DIS,0.01)

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_AIS=.
replace p_AIS=round(`p_AIS_SK',0.0001) if n==2
replace p_AIS=round(`p_AIS_BK',0.0001) if n==3
replace p_AIS=round(`p_AIS_NK',0.0001) if n==4

gen AIS_stars = "" 
	replace AIS_stars = "\sym{*}" if p_AIS >= 0.05 & p_AIS <0.10
	replace AIS_stars = "\sym{**}" if p_AIS >= 0.01 & p_AIS <0.05
	replace AIS_stars = "\sym{***}" if p_AIS >= 0.00 & p_AIS <0.01	

gen p_DIS=.
replace p_DIS=round(`p_DIS_SK',0.0001) if n==2
replace p_DIS=round(`p_DIS_BK',0.0001) if n==3
replace p_DIS=round(`p_DIS_NK',0.0001) if n==4

gen DIS_stars = "" 
	replace DIS_stars = "\sym{*}" if p_DIS >= 0.05 & p_DIS <0.10
	replace DIS_stars = "\sym{**}" if p_DIS >= 0.01 & p_DIS <0.05
	replace DIS_stars = "\sym{***}" if p_DIS >= 0.00 & p_DIS <0.01	
	

gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen AIS = string(mean_AIS, "%8.2f")+AIS_stars	
gen DIS = string(mean_DIS, "%8.2f")+DIS_stars	

keep treatment IS AIS DIS

listtex using "$out_dir_tbl/Fairness_shares_altdefn_allrounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccc} \toprule " ///
		 " & \multicolumn{3}{c}{\textbf{All 30 Rounds}} \\ \midrule  " ///
		 " \multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	

		
****************************************
***B8b. Alt Defn Inequality: First 10 rounds (absinequalityshare diffinequalityshare)
****************************************	
restore, preserve
keep if period<=10

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_AIS_SK = resultsmat[4,1]
	local p_AIS_BK = resultsmat[4,2]
	local p_AIS_NK = resultsmat[4,3]
	
reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_DIS_SK = resultsmat[4,1]
	local p_DIS_BK = resultsmat[4,2]
	local p_DIS_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_IS=inequalityshare ///
		 (mean) mean_AIS=absinequalityshare ///
		 (mean) mean_DIS=diffinequalityshare, by(treatment)
				
format mean_IS-mean_DIS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_IS=round(mean_IS,0.01)
replace mean_AIS=round(mean_AIS,0.01)
replace mean_DIS=round(mean_DIS,0.01)

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_AIS=.
replace p_AIS=round(`p_AIS_SK',0.0001) if n==2
replace p_AIS=round(`p_AIS_BK',0.0001) if n==3
replace p_AIS=round(`p_AIS_NK',0.0001) if n==4

gen AIS_stars = "" 
	replace AIS_stars = "\sym{*}" if p_AIS >= 0.05 & p_AIS <0.10
	replace AIS_stars = "\sym{**}" if p_AIS >= 0.01 & p_AIS <0.05
	replace AIS_stars = "\sym{***}" if p_AIS >= 0.00 & p_AIS <0.01	

gen p_DIS=.
replace p_DIS=round(`p_DIS_SK',0.0001) if n==2
replace p_DIS=round(`p_DIS_BK',0.0001) if n==3
replace p_DIS=round(`p_DIS_NK',0.0001) if n==4

gen DIS_stars = "" 
	replace DIS_stars = "\sym{*}" if p_DIS >= 0.05 & p_DIS <0.10
	replace DIS_stars = "\sym{**}" if p_DIS >= 0.01 & p_DIS <0.05
	replace DIS_stars = "\sym{***}" if p_DIS >= 0.00 & p_DIS <0.01	
	

gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen AIS = string(mean_AIS, "%8.2f")+AIS_stars	
gen DIS = string(mean_DIS, "%8.2f")+DIS_stars		

keep treatment IS AIS DIS

listtex using "$out_dir_tbl/Fairness_shares_altdefn_first10rounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccc} \toprule " ///
		 " & \multicolumn{3}{c}{\textbf{First 10 Rounds}} \\ \midrule  " ///
		 " \multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	

		
****************************************
***B8c. Alt Defn Inequality: Last 10 rounds (absinequalityshare diffinequalityshare)
****************************************	
restore, preserve
keep if period>20

*collect p-values to put into stars later
reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_IS_SK = resultsmat[4,1]
	local p_IS_BK = resultsmat[4,2]
	local p_IS_NK = resultsmat[4,3]
	
reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_AIS_SK = resultsmat[4,1]
	local p_AIS_BK = resultsmat[4,2]
	local p_AIS_NK = resultsmat[4,3]
	
reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
	mat resultsmat=r(table)
	local p_DIS_SK = resultsmat[4,1]
	local p_DIS_BK = resultsmat[4,2]
	local p_DIS_NK = resultsmat[4,3]	
	
*collapse to get means by treatment
collapse (mean) mean_IS=inequalityshare ///
		 (mean) mean_AIS=absinequalityshare ///
		 (mean) mean_DIS=diffinequalityshare, by(treatment)
				
format mean_IS-mean_DIS %8.2f	

*generate n to re-order with CI first
gen n = . 
	replace n = 1 if treatment==4
	replace n = 2 if treatment==2
	replace n = 3 if treatment==3
	replace n = 4 if treatment==1

tostring treatment, replace
replace treatment="Complete Information" if n==1
replace treatment="Seller Knows" if n==2
replace treatment="Buyer Knows" if n==3
replace treatment="Neither Knows" if n==4

sort n

*round the values to make it pretty
replace mean_IS=round(mean_IS,0.01)
replace mean_AIS=round(mean_AIS,0.01)
replace mean_DIS=round(mean_DIS,0.01)

gen p_IS=.
replace p_IS=round(`p_IS_SK',0.0001) if n==2
replace p_IS=round(`p_IS_BK',0.0001) if n==3
replace p_IS=round(`p_IS_NK',0.0001) if n==4

gen IS_stars = "" 
	replace IS_stars = "\sym{*}" if p_IS >= 0.05 & p_IS <0.10
	replace IS_stars = "\sym{**}" if p_IS >= 0.01 & p_IS <0.05
	replace IS_stars = "\sym{***}" if p_IS >= 0.00 & p_IS <0.01	
	
gen p_AIS=.
replace p_AIS=round(`p_AIS_SK',0.0001) if n==2
replace p_AIS=round(`p_AIS_BK',0.0001) if n==3
replace p_AIS=round(`p_AIS_NK',0.0001) if n==4

gen AIS_stars = "" 
	replace AIS_stars = "\sym{*}" if p_AIS >= 0.05 & p_AIS <0.10
	replace AIS_stars = "\sym{**}" if p_AIS >= 0.01 & p_AIS <0.05
	replace AIS_stars = "\sym{***}" if p_AIS >= 0.00 & p_AIS <0.01	

gen p_DIS=.
replace p_DIS=round(`p_DIS_SK',0.0001) if n==2
replace p_DIS=round(`p_DIS_BK',0.0001) if n==3
replace p_DIS=round(`p_DIS_NK',0.0001) if n==4

gen DIS_stars = "" 
	replace DIS_stars = "\sym{*}" if p_DIS >= 0.05 & p_DIS <0.10
	replace DIS_stars = "\sym{**}" if p_DIS >= 0.01 & p_DIS <0.05
	replace DIS_stars = "\sym{***}" if p_DIS >= 0.00 & p_DIS <0.01	
	

gen IS = string(mean_IS, "%8.2f")+IS_stars	
gen AIS = string(mean_AIS, "%8.2f")+AIS_stars	
gen DIS = string(mean_DIS, "%8.2f")+DIS_stars	

keep treatment IS AIS DIS

listtex using "$out_dir_tbl/Fairness_shares_altdefn_last10rounds_v2.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccc} \toprule " ///
		 " & \multicolumn{3}{c}{\textbf{Last 10 Rounds}} \\ \midrule  " ///
		 " \multirow{2}{*}{\textbf{Treatment:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
		 " & \textbf{Share} & \textbf{Share} & \textbf{Share}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	
	
****************************************
***B9. Reg - Alt Defn Inequality: All 30 rounds
****************************************
restore, preserve

***INEQUALITY SHARE: 		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)		
		
***ABSOLUTE INEQUALITY SHARE:		
	reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local AIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local AIStestBKvsNK: di %5.3f r(p)				

***DIFFERENCE INEQUALITY SHARE:		
	reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local DIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local DIStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_altdefn_allrounds_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l ccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} \\ " ///	        
				"\cmidrule(lr){2-4} & (1) & (2) & (3) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `IStestSKvsNK' & `AIStestSKvsNK' & `DIStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `IStestBKvsNK' & `AIStestBKvsNK' & `DIStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
		
****************************************
***B10. Reg - Alt Defn Inequality: First 10 rounds
****************************************
restore, preserve
keep if period<=10

***INEQUALITY SHARE: 		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)		
		
***ABSOLUTE INEQUALITY SHARE:		
	reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local AIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local AIStestBKvsNK: di %5.3f r(p)				

***DIFFERENCE INEQUALITY SHARE:		
	reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local DIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local DIStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_altdefn_first10rounds_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l ccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} \\ " ///	        
				"\cmidrule(lr){2-4} & (1) & (2) & (3) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `IStestSKvsNK' & `AIStestSKvsNK' & `DIStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `IStestBKvsNK' & `AIStestBKvsNK' & `DIStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
		
		
****************************************
***B11. Reg - Alt Defn Inequality: Last 10 rounds
****************************************
restore, preserve
keep if period>20

***INEQUALITY SHARE: 		
	reghdfe inequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local IStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local IStestBKvsNK: di %5.3f r(p)		
		
***ABSOLUTE INEQUALITY SHARE:		
	reghdfe absinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local AIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local AIStestBKvsNK: di %5.3f r(p)				

***DIFFERENCE INEQUALITY SHARE:		
	reghdfe diffinequalityshare sellerknows buyerknows nooneknows if buyer==1, absorb(temp) cluster(buyer_id seller_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			test _b[sellerknows]=_b[nooneknows]
				local DIStestSKvsNK: di %5.3f r(p)
			test _b[buyerknows]=_b[nooneknows]
				local DIStestBKvsNK: di %5.3f r(p)							

*export table code		
		esttab using "$out_dir_tbl/reg_shares_altdefn_last10rounds_v2.tex", ///
			keep(sellerknows buyerknows nooneknows _cons) ///
			order(sellerknows buyerknows nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}{l ccc} \toprule " ///
		        "\multirow{2}{*}{\textbf{Dependent Variable:}} & \textbf{Inequality} & \textbf{Absolute Inequality} & \textbf{Difference Inequality} \\ " ///
				" & \textbf{Share} & \textbf{Share} & \textbf{Share} \\ " ///	        
				"\cmidrule(lr){2-4} & (1) & (2) & (3) \\ ") ///
		prefoot("\midrule " ///
				" Test SK=NK p-value: & `IStestSKvsNK' & `AIStestSKvsNK' & `DIStestSKvsNK' \\ " ///
				"\midrule " ///
				" Test BK=NK p-value: & `IStestBKvsNK' & `AIStestBKvsNK' & `DIStestBKvsNK' \\ " ///
				"\midrule ") ///
			s(indcluster N r2, fmt(a3) label("Number of Clusters" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear
			


****************************************
***B12. Buyer Offer: 4 Panels - all 30 & LAST 10
****************************************	

restore, preserve	
****************************************
*********B12a. Regressions: Offer Removing Buyer Info | Seller Informed (SK v CI)
****************************************

*SK v CI

	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed) ALL	
	reg offer sellerknows if buyer==1 & treatment==2 | buyer==1 & treatment==4, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace

	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed)	VALUE70	
	reg offer sellerknows if buyer==1 & value==70 & treatment==2 | buyer==1 & value==70 & treatment==4, robust cluster(numeric_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			
	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed) VALUE90
	reg offer sellerknows if buyer==1 & value==90 & treatment==2 | buyer==1 & value==90 & treatment==4, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace	
			
	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed) ALL	
	reg offer sellerknows if buyer==1 & treatment==2 & period>20 | buyer==1 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace

	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed)	VALUE70	
	reg offer sellerknows if buyer==1 & value==70 & treatment==2 & period>20 | buyer==1 & value==70 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo E
			estadd local indcluster `e(N_clust)', replace
			
	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed) VALUE90
	reg offer sellerknows if buyer==1 & value==90 & treatment==2 & period>20 | buyer==1 & value==90 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace				

*export table code		
		esttab using "$out_dir_tbl/reg_offer_SKvCI_all30last10.tex", ///
			keep(sellerknows _cons) ///
			order(sellerknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{3}{c}{\textbf{All 30 Rounds}} & \multicolumn{3}{c}{\textbf{Last 10 Rounds}} \\ " ///
				"& \multicolumn{6}{c}{\textbf{SK vs CI}} \\ " ///
				"& All & Value=70 & Value=90 & All & Value=70 & Value=90 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Buyers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	

****************************************
*********B12b. Regressions: Offer Removing Buyer Info | Seller Uninformed (NK v BK)
****************************************

*NK v BK 

	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed) ALL	
	reg offer nooneknows if buyer==1 & treatment==1 | buyer==1 & treatment==3, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace

	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed)	VALUE70	
	reg offer nooneknows if buyer==1 & value==70 & treatment==1 | buyer==1 & value==70 & treatment==3, robust cluster(numeric_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			
	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed) VALUE90
	reg offer nooneknows if buyer==1 & value==90 & treatment==1 | buyer==1 & value==90 & treatment==3, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace	
			
	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed) ALL	
	reg offer nooneknows if buyer==1 & treatment==1 & period>20 | buyer==1 & treatment==3 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace

	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed)	VALUE70	
	reg offer nooneknows if buyer==1 & value==70 & treatment==1 & period>20 | buyer==1 & value==70 & treatment==3 & period>20, robust cluster(numeric_id)
			eststo E
			estadd local indcluster `e(N_clust)', replace
			
	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed) VALUE90
	reg offer nooneknows if buyer==1 & value==90 & treatment==1 & period>20 | buyer==1 & value==90 & treatment==3 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace			

*export table code		
		esttab using "$out_dir_tbl/reg_offer_NKvBK_all30last10.tex", ///
			keep(nooneknows _cons) ///
			order(nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{NK vs BK}} \\ " ///
				"& All & Value=70 & Value=90 & All & Value=70 & Value=90 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Buyers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear		
		
****************************************
*********B12c. Regressions: Offer Removing Seller Info | Buyer Informed (BK v CI)
****************************************
*BK v CI

	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed) ALL	
	reg offer buyerknows if buyer==1 & treatment==3 | buyer==1 & treatment==4, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace

	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed)	VALUE70	
	reg offer buyerknows if buyer==1 & value==70 & treatment==3 | buyer==1 & value==70 & treatment==4, robust cluster(numeric_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			
	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed) VALUE90
	reg offer buyerknows if buyer==1 & value==90 & treatment==3 | buyer==1 & value==90 & treatment==4, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace

	*Last 10 Rounds: BKvCI (Seller Informed | Buyer Informed) ALL	
	reg offer buyerknows if buyer==1 & treatment==3 & period>20 | buyer==1 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace

	*Last 10 Rounds BKvCI (Seller Informed | Buyer Informed)	VALUE70	
	reg offer buyerknows if buyer==1 & value==70 & treatment==3 & period>20 | buyer==1 & value==70 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo E
			estadd local indcluster `e(N_clust)', replace
			
	*Last 10 Rounds: BKvCI (Seller Informed | Buyer Informed) VALUE90
	reg offer buyerknows if buyer==1 & value==90 & treatment==3 & period>20 | buyer==1 & value==90 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace
			
*export table code		
		esttab using "$out_dir_tbl/reg_offer_BKvCI_all30last10.tex", ///
			keep(buyerknows _cons) ///
			order(buyerknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{BK vs CI}} \\ " ///
				"& All & Value=70 & Value=90 & All & Value=70 & Value=90 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Buyers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	
		
****************************************
*********B12d. Regressions: Offer Removing Seller Info | Buyer Uninformed (NK v SK)
****************************************

*NK v SK 	

	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed) ALL	
	reg offer nooneknows if buyer==1 & treatment==1 | buyer==1 & treatment==2, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace

	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed)	VALUE70	
	reg offer nooneknows if buyer==1 & value==70 & treatment==1 | buyer==1 & value==70 & treatment==2, robust cluster(numeric_id)
			eststo B
			estadd local indcluster `e(N_clust)', replace
			
	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed) VALUE90
	reg offer nooneknows if buyer==1 & value==90 & treatment==1 | buyer==1 & value==90 & treatment==2, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace				

	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed) ALL	
	reg offer nooneknows if buyer==1 & treatment==1 & period>20 | buyer==1 & treatment==2 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace

	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed)	VALUE70	
	reg offer nooneknows if buyer==1 & value==70 & treatment==1 & period>20 | buyer==1 & value==70 & treatment==2 & period>20, robust cluster(numeric_id)
			eststo E
			estadd local indcluster `e(N_clust)', replace
			
	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed) VALUE90
	reg offer nooneknows if buyer==1 & value==90 & treatment==1 & period>20 | buyer==1 & value==90 & treatment==2 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace	
			
*export table code		
		esttab using "$out_dir_tbl/reg_offer_NKvSK_all30last10.tex", ///
			keep(nooneknows _cons) ///
			order(nooneknows _cons) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{NK vs SK}} \\ " ///
				"& All & Value=70 & Value=90 & All & Value=70 & Value=90 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Buyers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}")
		eststo clear			

****************************************
***B13. Seller Accept: 4 Panels - all 30 & LAST 10
****************************************	
		
****************************************
*********B13a. Regressions: Accepted Removing Buyer Info | Seller Informed (SK v CI)
****************************************

*SK v CI

	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed) ALL	
	reg accept sellerknows i.offer#i.cost if buyer==0 & treatment==2 | buyer==0 & treatment==4, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed)	COST10	
	reg accept sellerknows i.offer if buyer==0 & cost==10 & treatment==2 | buyer==0 & cost==10 & treatment==4, robust cluster(numeric_id)			
			eststo B
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*All 30 Rounds: SKvCI (Buyer Informed | Seller Informed) COST 30
	reg accept sellerknows i.offer if buyer==0 & cost==30 & treatment==2 | buyer==0 & cost==30 & treatment==4, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed) ALL	
	reg accept sellerknows i.offer#i.cost if buyer==0 & treatment==2 & period>20 | buyer==0 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed)	COST10	
	reg accept sellerknows i.offer if buyer==0 & cost==10 & treatment==2 & period>20 | buyer==0 & cost==10 & treatment==4 & period>20, robust cluster(numeric_id)			
			eststo E
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: SKvCI (Buyer Informed | Seller Informed) COST 30
	reg accept sellerknows i.offer if buyer==0 & cost==30 & treatment==2 & period>20 | buyer==0 & cost==30 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace			

*export table code		
		esttab using "$out_dir_tbl/reg_accept_SKvCI_all30last10.tex", ///
			keep(sellerknows) ///
			order(sellerknows) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{3}{c}{\textbf{All 30 Rounds}} & \multicolumn{3}{c}{\textbf{Last 10 Rounds}} \\ " ///
				"& \multicolumn{6}{c}{\textbf{SK vs CI}} \\ " ///
				"& All & Cost=10 & Cost=30 & All & Cost=10 & Cost=30 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Sellers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	



****************************************
*********B13b. Regressions: Accepted Removing Buyer Info | Seller Uninformed  (NK v BK)
****************************************

*NK v BK
	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed) ALL	
	reg accept nooneknows i.offer#i.cost if buyer==0 & treatment==1 | buyer==0 & treatment==3, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed)	COST10	
	reg accept nooneknows i.offer if buyer==0 & cost==10 & treatment==1 | buyer==0 & cost==10 & treatment==3, robust cluster(numeric_id)			
			eststo B
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*All 30 Rounds: NKvBK (Buyer Informed | Seller Uninformed) COST 30
	reg accept nooneknows i.offer if buyer==0 & cost==30 & treatment==1 | buyer==0 & cost==30 & treatment==3, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace		
	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed) ALL	
	reg accept nooneknows i.offer#i.cost if buyer==0 & treatment==1 & period>20 | buyer==0 & treatment==3 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed)	COST10	
	reg accept nooneknows i.offer if buyer==0 & cost==10 & treatment==1 & period>20 | buyer==0 & cost==10 & treatment==3 & period>20, robust cluster(numeric_id)			
			eststo E
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: NKvBK (Buyer Informed | Seller Uninformed) COST 30
	reg accept nooneknows i.offer if buyer==0 & cost==30 & treatment==1 & period>20 | buyer==0 & cost==30 & treatment==3 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
*export table code		
		esttab using "$out_dir_tbl/reg_accept_NKvBK_all30last10.tex", ///
			keep(nooneknows) ///
			order(nooneknows) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{NK vs BK}} \\ " ///
				"& All & Cost=10 & Cost=30 & All & Cost=10 & Cost=30 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Sellers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	

****************************************
*********B13c. Regressions: Accepted Removing Seller Info | Buyer Informed (BK v CI)
****************************************

*BK v CI
	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed) ALL	
	reg accept buyerknows i.offer#i.cost if buyer==0 & treatment==3 | buyer==0 & treatment==4, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed)	COST10	
	reg accept buyerknows i.offer if buyer==0 & cost==10 & treatment==3 | buyer==0 & cost==10 & treatment==4, robust cluster(numeric_id)			
			eststo B
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*All 30 Rounds: BKvCI (Seller Informed | Buyer Informed) COST 30
	reg accept buyerknows i.offer if buyer==0 & cost==30 & treatment==3 | buyer==0 & cost==30 & treatment==4, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
	*Last 10 Rounds: BKvCI (Seller Informed | Buyer Informed) ALL	
	reg accept buyerknows i.offer#i.cost if buyer==0 & treatment==3 & period>20 | buyer==0 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*Last 10 Rounds: BKvCI (Seller Informed | Buyer Informed)	COST10	
	reg accept buyerknows i.offer if buyer==0 & cost==10 & treatment==3 & period>20 | buyer==0 & cost==10 & treatment==4 & period>20, robust cluster(numeric_id)			
			eststo E
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: BKvCI (Seller Informed | Buyer Informed) COST 30
	reg accept buyerknows i.offer if buyer==0 & cost==30 & treatment==3 & period>20 | buyer==0 & cost==30 & treatment==4 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
			
*export table code		
		esttab using "$out_dir_tbl/reg_accept_BKvCI_all30last10.tex", ///
			keep(buyerknows) ///
			order(buyerknows) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{BK vs CI}} \\ " ///
				"& All & Cost=10 & Cost=30 & All & Cost=10 & Cost=30 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Sellers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	


****************************************
*********B13d. Regressions: Accepted Removing Seller Info | Buyer Uninformed (NK v SK)
****************************************

*NK v SK

	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed) ALL	
	reg accept nooneknows i.offer#i.cost if buyer==0 & treatment==1 | buyer==0 & treatment==2, robust cluster(numeric_id)
			eststo A
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed)	COST10	
	reg accept nooneknows i.offer if buyer==0 & cost==10 & treatment==1 | buyer==0 & cost==10 & treatment==2, robust cluster(numeric_id)			
			eststo B
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*All 30 Rounds: NKvSK (Seller Informed | Buyer Uninformed) COST 30
	reg accept nooneknows i.offer if buyer==0 & cost==30 & treatment==1 | buyer==0 & cost==30 & treatment==2, robust cluster(numeric_id)
			eststo C
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed) ALL	
	reg accept nooneknows i.offer#i.cost if buyer==0 & treatment==1 & period>20 | buyer==0 & treatment==2 & period>20, robust cluster(numeric_id)
			eststo D
			estadd local indcluster `e(N_clust)', replace
			estadd local offercostdummy "Yes", replace

	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed)	COST10	
	reg accept nooneknows i.offer if buyer==0 & cost==10 & treatment==1 & period>20 | buyer==0 & cost==10 & treatment==2 & period>20, robust cluster(numeric_id)			
			eststo E
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace
			
	*Last 10 Rounds: NKvSK (Seller Informed | Buyer Uninformed) COST 30
	reg accept nooneknows i.offer if buyer==0 & cost==30 & treatment==1 & period>20 | buyer==0 & cost==30 & treatment==2 & period>20, robust cluster(numeric_id)
			eststo F
			estadd local indcluster `e(N_clust)', replace
			estadd local offerdummy "Yes", replace				

*export table code		
		esttab using "$out_dir_tbl/reg_accept_NKvSK_all30last10.tex", ///
			keep(nooneknows) ///
			order(nooneknows) ///
		nonote booktabs se ar2 nonumb nomtitles compress replace label collabels(none) ///
		cells(b(star fmt(%9.3f)) se(par)) ///
		prehead("\begin{tabular}[t]{L{6cm} ccc | ccc} \toprule " ///
				"& \multicolumn{6}{c}{\textbf{NK vs SK}} \\ " ///
				"& All & Cost=10 & Cost=30 & All & Cost=10 & Cost=30 \\ " ///				
		        "\cmidrule(lr){2-7}  & (1) & (2) & (3) & (4) & (5) & (6) \\ ") ///
			s(indcluster N r2, fmt(a3) label("Number of Sellers (Clusters)" "Observations" "R-Squared")) ///
		star(* 0.10 ** 0.05 *** 0.01) /// 
		postfoot("\hline \end{tabular}") 
		eststo clear	

restore
		
****************************************
***B14a. KS-test: Seller Beliefs v. Reality NK
****************************************
use fairness_part2, replace

sort subj_id

gen probvalue=probBDM/100
gen probactualvalue=.
	replace probactualvalue=1 if oldvalue==70
	replace probactualvalue=0 if oldvalue==90	 

matrix define kstest_NK=J(2,7,.)
matrix list kstest_NK
	
****KS TEST: 
	preserve
	*keep relevant variables
	keep if treatment==1 & buyer==0
	keep subj_id period probvalue probactualvalue oldoffer oldcost buyer treatment
	*double data 
	expand 2 

	*gen indicator for actual prob
	bys subj_id period: gen n=_n
	
	gen actual=0
		replace actual=1 if n==2
		
	*gen one variable for probvalue and probactualvalue
	gen beliefactualprob=probvalue
		replace beliefactualprob=probactualvalue if actual==1
	
	ksmirnov beliefactualprob if oldcost==10, by(actual) exact
		mat kstest_NK[1,1] = r(D_1)
		mat kstest_NK[1,2] = r(p_1)
		mat kstest_NK[1,3] = r(D_2)
		mat kstest_NK[1,4] = r(p_2)
		mat kstest_NK[1,5] = r(D)
		mat kstest_NK[1,6] = r(p)
		mat kstest_NK[1,7] = r(p_exact)
		
	ksmirnov beliefactualprob if oldcost==30, by(actual) exact
		mat kstest_NK[2,1] = r(D_1)
		mat kstest_NK[2,2] = r(p_1)
		mat kstest_NK[2,3] = r(D_2)
		mat kstest_NK[2,4] = r(p_2)
		mat kstest_NK[2,5] = r(D)
		mat kstest_NK[2,6] = r(p)
		mat kstest_NK[2,7] = r(p_exact)
		
	ksmirnov beliefactualprob if oldcost==10 & oldoffer>=20 & oldoffer<=60 , by(actual) exact
	ksmirnov beliefactualprob if oldcost==30 & oldoffer>=20 & oldoffer<=60 , by(actual) exact
	
*****Regression Test
	egen numeric_id=group(subj_id)	
	reg beliefactualprob actual oldoffer if oldcost==10, robust cluster(numeric_id)
	reg beliefactualprob actual oldoffer if oldcost==30, robust cluster(numeric_id)
	reg beliefactualprob actual i.oldoffer#i.oldcost, robust cluster(numeric_id)

	
**format for output	
svmat kstest_NK
keep kstest_NK* 
drop if kstest_NK1 ==.
gen n=_n
gen testgroup = ""
	replace testgroup = "NK, cost = 10" if n==1
	replace testgroup = "NK, cost = 30" if n==2
order testgroup
drop n

format kstest_NK1-kstest_NK7 %8.3f	

* store
listtex using "$out_dir_tbl/kstest_NK.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccccc} \toprule " ///
		 " & \multicolumn{7}{c}{\textbf{Seller Beliefs vs Reality: Neither Knows (NK)}} \\ \midrule  " ///
		 "\textbf{Treatment:} & \textbf{Belief} & \textbf{p-value} & \textbf{Actual} & \textbf{p-value} & \textbf{Combined} & \textbf{p-value}  & \textbf{Exact p-value}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	
	
restore

****************************************
***B14b. KS-test: Seller Beliefs v. Reality BK
****************************************

matrix define kstest_BK=J(2,7,.)
matrix list kstest_BK

****KS TEST: 
	preserve
	*keep relevant variables
	keep if treatment==3 & buyer==0
	keep subj_id period probvalue probactualvalue oldoffer oldcost buyer treatment
	*double data 
	expand 2 

	*gen indicator for actual prob
	bys subj_id period: gen n=_n
	
	gen actual=0
		replace actual=1 if n==2
		
	*gen one variable for probvalue and probactualvalue
	gen beliefactualprob=probvalue
		replace beliefactualprob=probactualvalue if actual==1
	
	ksmirnov beliefactualprob if oldcost==10, by(actual) exact
		mat kstest_BK[1,1] = r(D_1)
		mat kstest_BK[1,2] = r(p_1)
		mat kstest_BK[1,3] = r(D_2)
		mat kstest_BK[1,4] = r(p_2)
		mat kstest_BK[1,5] = r(D)
		mat kstest_BK[1,6] = r(p)
		mat kstest_BK[1,7] = r(p_exact)
		
	ksmirnov beliefactualprob if oldcost==30, by(actual) exact
		mat kstest_BK[2,1] = r(D_1)
		mat kstest_BK[2,2] = r(p_1)
		mat kstest_BK[2,3] = r(D_2)
		mat kstest_BK[2,4] = r(p_2)
		mat kstest_BK[2,5] = r(D)
		mat kstest_BK[2,6] = r(p)
		mat kstest_BK[2,7] = r(p_exact)
		
	ksmirnov beliefactualprob if oldcost==10 & oldoffer>=20 & oldoffer<=55 , by(actual) exact
	ksmirnov beliefactualprob if oldcost==30 & oldoffer>=20 & oldoffer<=55 , by(actual) exact
	
*****Regression Test
	egen numeric_id=group(subj_id)	
	reg beliefactualprob actual oldoffer if oldcost==10, robust cluster(numeric_id)
	reg beliefactualprob actual oldoffer if oldcost==30, robust cluster(numeric_id)
	reg beliefactualprob actual i.oldoffer#i.oldcost, robust cluster(numeric_id)
	
	
**format for output	
svmat kstest_BK
keep kstest_BK* 
drop if kstest_BK1 ==.
gen n=_n
gen testgroup = ""
	replace testgroup = "BK, cost = 10" if n==1
	replace testgroup = "BK, cost = 30" if n==2
order testgroup
drop n

format kstest_BK1-kstest_BK7 %8.3f	

* store
listtex using "$out_dir_tbl/kstest_BK.tex", replace ///
	rstyle(tabular) ///
	head("\begin{tabular*}{\textwidth}{l  @{\extracolsep{\fill}} ccccccc} \toprule " ///
		 " & \multicolumn{7}{c}{\textbf{Seller Beliefs vs Reality: Buyer Knows (BK)}} \\ \midrule  " ///
		 "\textbf{Treatment:} & \textbf{Belief} & \textbf{p-value} & \textbf{Actual} & \textbf{p-value} & \textbf{Combined} & \textbf{p-value}  & \textbf{Exact p-value}\\ " ///
		 "\midrule") ///
	foot("\bottomrule \end{tabular*}") 	

restore 

*END CODE

